<template>
  <div class="container">
    <!-- <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>项目申报</el-breadcrumb-item>
            <el-breadcrumb-item>新建项目申报</el-breadcrumb-item>
        </el-breadcrumb> -->

    <topTitle
      :titleText="titleText"
      :titleExplain="titleExplain"
      :back="back"
      @gobackTriser="goBackList"
    ></topTitle>
    <div class="mainCon">
      <el-row class="tipBar2">
        <el-col class="hint">
          <div class="imgLabel">
            <img
              src="../../../static/img/declare/declarePro.png"
              class="picCss"
            />
          </div>
          <div class="hintCss">
            <div>1.申报项目</div>
            <span class="fontCss">施工方申报项目</span>
          </div>
        </el-col>
        <el-col class="stepCss">
          <img src="../../../static/img/salary/stepLine.png" class="lineCss" />
        </el-col>
        <el-col class="hint">
          <div class="imgLabel">
            <img
              src="../../../static/img/declare/auditReport.png"
              class="picCss"
            />
          </div>
          <div class="hintCss">
            <div>2.等待审核</div>
            <span class="fontCss">等待当地监管部门审核申报内容</span>
          </div>
        </el-col>
        <el-col class="stepCss">
          <img src="../../../static/img/salary/stepLine.png" class="lineCss" />
        </el-col>
        <el-col class="hint">
          <div class="imgLabel">
            <img
              src="../../../static/img/declare/approved.png"
              class="picCss"
            />
          </div>
          <div class="hintCss">
            <div>
              3.审核通过
              <el-tooltip content="Top center" placement="top" effect="dark">
                <div slot="content">
                  审核驳回怎么办？根据监管部门驳回理由<br />修改项目信息后重新申报即可
                </div>
                <i class="icon iconfont iconhuabanfuben"></i>
              </el-tooltip>
            </div>
            <el-tooltip
              content="Bottom center"
              placement="bottom"
              effect="dark"
            >
              <div slot="content">
                审核通过后企业可管理项目，项目经理<br />可使用手机号码注册账号管理项目
              </div>
              <span class="fontCss ellipsis"
                >审核通过后企业可管理项目,项目经理可使用手机号码注册账号管理项目</span
              >
            </el-tooltip>
          </div>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <div class="mainC">
        <el-form
          :model="formData"
          :rules="formRules"
          ref="formData"
          label-width="164px"
          class="demo-ruleForm"
        >
          <el-row>
            <el-col>
              <div class="secondaryTitle secondaryTitleTheme mrB30">
                项目基本信息
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="projectName" label="项目名称：">
                      <el-input
                        v-model.trim="formData.projectName"
                        placeholder="请输入项目完整名称"
                        class="proInputWidth"
                        clearable
                        filterable
                        @blur="validProName"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="施工许可证："
                      label-width="164px"
                      :rules="
                        isNeedLicense == 1
                          ? {
                              required: true,
                              message: '施工许可证不能为空',
                              trigger: 'blur ',
                            }
                          : { required: false, trigger: 'blur' }
                      "
                      prop="license"
                    >
                      <el-input
                        v-model.trim="formData.license"
                        placeholder="请输入施工许可证编号"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="projectStatus" label="项目状态：">
                      <el-select
                        clearable
                        filterable
                        placeholder="请选择"
                        class="proInputWidth"
                        v-model.trim="formData.projectStatus"
                      >
                        <el-option
                          v-for="item in projectStatus"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="areaId" label="所属区域：">
                      <el-cascader
                        v-model="areaId"
                        :options="areaIdOpt"
                        @change="getAreaId"
                        clearable
                        filterable
                        placeholder="请选择"
                        class="proInputWidth"
                      ></el-cascader>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="industry" label="所属行业：">
                      <el-select
                        clearable
                        filterable
                        placeholder="请选择"
                        class="proInputWidth"
                        v-model="formData.industry"
                      >
                        <el-option
                          v-for="item in industry"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="category" label="投资类别：">
                      <el-select
                        clearable
                        filterable
                        placeholder="请选择"
                        class="proInputWidth"
                        v-model="formData.category"
                      >
                        <el-option
                          v-for="item in investmentOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="projectCost" label="工程造价：">
                      <el-input
                        v-model.trim="formData.projectCost"
                        placeholder="请输入工程造价"
                        class="minInputWidth"
                        clearable
                      ></el-input>
                      元
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="startDate" label="开工日期：">
                      <el-date-picker
                        type="date"
                        placeholder="请选择"
                        v-model="formData.startDate"
                        class="proInputWidth"
                        clearable
                        value-format="yyyy-MM-dd"
                      ></el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="constructionCycle" label="建设周期：">
                      <el-input
                        v-model.trim="formData.constructionCycle"
                        placeholder="请输入建设周期"
                        class="minInputWidth"
                        clearable
                      ></el-input>
                      天
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      prop="detailAddress"
                      label="项目部详细地址："
                      :rules="
                        isNeedAddress == 0
                          ? [{ required: false }]
                          : formRules.detailAddress
                      "
                    >
                      <div style="position: relative">
                        <el-input
                          v-model.trim="formData.detailAddress"
                          placeholder="请输入项目部详细地址，并在地图上确定详细位置"
                          class="proInputWidth"
                          id="suggestId"
                          ref="inputDetailAdr"
                          @blur="hideMap"
                        ></el-input>
                        <!--@blur = "hideMap"-->
                        <div
                          style="
                            width: 62%;
                            height: 33px;
                            background: #fff;
                            position: absolute;
                            top: 3px;
                            left: 3px;
                            z-index: 10;
                            opacity: 0;
                          "
                          @click="showMap"
                          v-if="isShowBox"
                          id="showBox"
                        ></div>
                        <div
                          id="searchResultPanel"
                          style="
                            border: 1px solid #c0c0c0;
                            width: 150px;
                            height: auto;
                            display: none;
                          "
                        ></div>
                      </div>
                      <el-row class="row-padding-bottom" v-if="isShowMap">
                        <el-col :span="24" class="col-position">
                          <div
                            id="l-map"
                            style="
                              height: 300px;
                              position: absolute;
                              width: 70%;
                              z-index: 1000;
                            "
                          ></div>
                        </el-col>
                      </el-row>

                      <!-- 获取当前地址  -->
                      <div id="allmap"></div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="projectType" label="工程类型：">
                      <el-select
                        clearable
                        filterable
                        placeholder="请选择"
                        class="proInputWidth"
                        v-model="formData.projectType"
                      >
                        <el-option
                          v-for="item in projectType"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12" v-if="isWhUser()">
                    <el-form-item
                      prop="isStateOwnedConstruction"
                      label="是否国企施工项目："
                      label-width="164px"
                      :rules="
                        isNeedIsStateOwned == 0
                          ? [{ required: false }]
                          : formRules.isStateOwnedConstruction
                      "
                    >
                      <el-select
                        clearable
                        filterable
                        placeholder="请选择项目的施工总承包企业是否属于国有企业"
                        class="proInputWidth"
                        v-model="formData.isStateOwnedConstruction"
                      >
                        <el-option label="是" value="1"></el-option>
                        <el-option label="否" value="0"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      prop="constructLocation"
                      label="施工地址："
                      :rules="
                        isNeedConstructLocation == 0
                          ? [{ required: false }]
                          : formRules.constructLocation
                      "
                    >
                      <el-input
                        v-model.trim="formData.constructLocation"
                        placeholder="请输入施工详细地址"
                        class="proInputWidth"
                        clearable
                        @blur="formData.constructLocation = changeValue($event)"
                      ></el-input>
                      <!-- <textarea name="" id="" cols="10" rows="1" v-model.trim="formData.constructLocation" placeholder="请输入施工详细地址" class = "proInputWidth" clearable @blur="formData.constructLocation = changeValue($event)"></textarea> -->
                    </el-form-item>
                  </el-col>
                  <!-- </el-row>
                        <el-row> -->
                  <el-col :span="12">
                    <el-form-item label="工资发放日：" prop="salaryDay">
                      <el-select
                        placeholder="请选择"
                        v-model.trim="formData.salaryDay"
                        clearable
                        filterable
                        class="proInputWidth"
                      >
                        <el-option
                          v-for="(item, index) in salaryDayList"
                          :key="index"
                          :label="item"
                          :value="item"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12" v-if="isXiangYangUser()">
                    <el-form-item
                      label="合同签订日："
                      label-width="164px"
                      prop="contractSignDate"
                      :rules="
                        isNeedContractSignDate == 0
                          ? [{ required: false }]
                          : formRules.contractSignDate
                      "
                    >
                      <el-date-picker
                        type="date"
                        placeholder="请选择"
                        v-model="formData.contractSignDate"
                        value-format="yyyy-MM-dd"
                        class="proInputWidth"
                        clearable
                      ></el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row v-if="isWhUser()">
                  <el-col :span="24">
                    <el-form-item
                      label="施工许可证："
                      class="upLoadDomContainer"
                      label-width="164px"
                    >
                      <uploadAnnex
                        @getFileList="getFileListLicense"
                        :limitationFactor="limitationFactorLicense"
                        @getFile="getFileLicense"
                        :upLoadFile="upLoadFileLicense"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <uploadResult
                      style="margin-left: 120px"
                      :resultList="upLoadFileLicense"
                      @callBackResult="getFileLicense"
                    />
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item
                      label="开工令："
                      class="upLoadDomContainer"
                      label-width="164px"
                      :rules="
                        isNeedOrdFiles == 0
                          ? [{ required: false }]
                          : formRules.upLoadFileOrder
                      "
                      prop="upLoadFileOrder"
                    >
                      <uploadAnnex
                        @getFileList="getFileListOrder"
                        :limitationFactor="limitationFactorOrder"
                        @getFile="getFileOrder"
                        :upLoadFile="upLoadFileOrder"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <!-- <elementImage :upLoadFile="upLoadFileOrder" :srcList="srcListOrder" :oldSrcList="oldSrcListOrder" @changeSrcList="changeSrcListOrder"></elementImage> -->
                    <uploadResult
                      style="margin-left: 120px"
                      :resultList="upLoadFileOrder"
                      @callBackResult="getFileOrder"
                    />
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-divider></el-divider>
          <el-row>
            <el-col>
              <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
                建设方信息
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="unitName" label="单位名称：">
                      <el-input
                        v-model="formData.unitName"
                        @change="
                          validUsccAndCompany(
                            formData.unitName,
                            formData.jsUscc
                          )
                        "
                        placeholder="请输入单位名称"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="jsUscc" label="统一社会信用代码：">
                      <el-input
                        v-model="formData.jsUscc"
                        @change="
                          validUsccAndCompany(
                            formData.unitName,
                            formData.jsUscc
                          )
                        "
                        placeholder="请输入统一社会信用代码"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item
                      prop="pcLeader"
                      :rules="
                        isNeedPcLeader == 0
                          ? [{ required: false }]
                          : formRules.pcLeader
                      "
                    >
                      <span slot="label"
                        >项目负责人
                        <el-tooltip
                          content="Top center"
                          placement="top"
                          effect="dark"
                        >
                          <div slot="content">业主单位负责管理该项目的人员</div>
                          <i
                            class="icon iconfont iconhuabanfuben"
                          ></i> </el-tooltip
                        >：
                      </span>
                      <el-input
                        v-model.trim="formData.pcLeader"
                        placeholder="请输入项目全权负责人姓名"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="负责人手机号码："
                      prop="pcLeaderTel"
                      :rules="
                        isNeedPcLeaderTel == 0
                          ? [{ required: false }]
                          : formRules.pcLeaderTel
                      "
                    >
                      <el-input
                        v-model.trim="formData.pcLeaderTel"
                        placeholder="请输入项目全权负责人手机号码"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-divider></el-divider>
          <el-row>
            <el-col>
              <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
                施工方信息
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-row>
                  <el-col :span="12">
                    <el-form-item prop="companyName" label="单位名称：">
                      <!-- <el-input v-model="formData.companyName"  placeholder="请输入项目完整名称" class = "proInputWidth" clearable filterable></el-input> -->
                      <span>{{ nickname }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="uscc" label="统一社会信用代码：">
                      <!-- <el-input v-model="formData.uscc"  placeholder="请输入统一社会信用代码" class = "proInputWidth" clearable filterable @blur="formData.uscc = changeValue($event)"></el-input> -->
                      <span>{{ sgUscc }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item
                      prop="leader"
                      :rules="
                        isNeedLeader == 0
                          ? [{ required: false }]
                          : formRules.leader
                      "
                    >
                      <span slot="label">
                        项目负责人
                        <el-tooltip
                          content="Top center"
                          placement="top"
                          effect="dark"
                        >
                          <div slot="content">
                            施工单位负责管理项目的人员，建档后项目账号将发送至负责人手机号
                          </div>
                          <i
                            class="icon iconfont iconhuabanfuben"
                          ></i> </el-tooltip
                        >：
                      </span>
                      <el-input
                        v-model.trim="formData.leader"
                        placeholder="请输入项目全权负责人姓名"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      prop="leaderTel"
                      label="负责人手机号码："
                      :rules="
                        isNeedLeaderTel == 0
                          ? [{ required: false }]
                          : formRules.leaderTel
                      "
                    >
                      <el-input
                        v-model.trim="formData.leaderTel"
                        placeholder="请输入项目全权负责人手机号码"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-divider></el-divider>
          <el-row>
            <el-col>
              <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
                项目经理信息
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-row>
                  <el-col :span="12">
                    <el-form-item
                      prop="proManagerName"
                      label="项目经理姓名："
                      :rules="
                        isNeedManagerName == 1
                          ? formRules.proManagerName
                          : { required: false, trigger: 'blur' }
                      "
                    >
                      <el-input
                        v-model.trim="formData.proManagerName"
                        placeholder="请输入项目经理姓名"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      prop="proManagerCard"
                      label="项目经理身份证号："
                      :rules="
                        isNeedManagerIdcard == 0
                          ? [
                              {
                                required: false,
                                pattern:
                                  /^(([1-9][0-9]{5}(19|20)[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}([0-9]|X|x))|([1-9][0-9]{5}[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}))$/,
                                message: '请输入正确的身份证号',
                                trigger: 'blur',
                              },
                            ]
                          : formRules.proManagerCard
                      "
                    >
                      <el-input
                        v-model.trim="formData.proManagerCard"
                        placeholder="请输入项目经理身份证号"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item
                      prop="proManagerTel"
                      label="项目经理手机号："
                      :rules="
                        isNeedManagerTel == 0
                          ? [
                              {
                                required: false,
                                pattern: /^1[3456789]\d{9}$/,
                                message: '请输入正确的手机号码',
                                trigger: 'blur',
                              },
                            ]
                          : formRules.proManagerTel
                      "
                    >
                      <el-input
                        v-model.trim="formData.proManagerTel"
                        placeholder="请输入项目经理手机号"
                        class="proInputWidth"
                        clearable
                        filterable
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item
                      label="项目经理资格证书："
                      label-width="164px"
                      prop="managerUpLoadFile"
                      :rules="
                        isNeedMgFiles == 0
                          ? [{ required: false }]
                          : formRules.managerUpLoadFile
                      "
                    >
                      <uploadAnnex
                        @getFileList="getFileListManager"
                        :limitationFactor="limitationFactorManager"
                        @getFile="getFileManager"
                        :upLoadFile="managerUpLoadFile"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24" v-model="formData.managerImgUrl">
                    <!-- <elementImage :upLoadFile="managerUpLoadFile"   :srcList="managerSrcList" :oldSrcList="managerOldSrcList" @changeSrcList="changeManagerSrcList"></elementImage> -->
                    <uploadResult
                      style="margin-left: 120px"
                      :resultList="managerUpLoadFile"
                      @callBackResult="getFileManager"
                    />
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item
                      label="项目经理企业任命文件："
                      class="warpLabel"
                      label-width="164px"
                      prop="manUploadFiles"
                      :rules="
                        isAppointJson == 0
                          ? [{ required: false }]
                          : formRules.manUploadFiles
                      "
                    >
                      <uploadAnnex
                        @getFileList="getFileListManFiles"
                        :limitationFactor="limitationFactorManFiles"
                        @getFile="getFileManFiles"
                        :upLoadFile="manUploadFiles"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24" v-model="formData.managerImgUrl">
                    <uploadResult
                      style="margin-left: 120px"
                      :resultList="manUploadFiles"
                      @callBackResult="getFileManFiles"
                    />
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-divider></el-divider>
          <el-row>
            <el-col>
              <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
                合同信息
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-row>
                  <el-col :span="24">
                    <el-form-item
                      label="合同附件："
                      label-width="164px"
                      :rules="
                        isNeedUpLoadFile == 0
                          ? [{ required: false }]
                          : formRules.upLoadFile
                      "
                      prop="upLoadFile"
                    >
                      <uploadAnnex
                        @getFileList="getFileList"
                        :limitationFactor="limitationFactor"
                        @getFile="getFile"
                        :upLoadFile="upLoadFile"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24" v-model="formData.contractImgUrl">
                    <!-- <elementImage :upLoadFile="upLoadFile"   :srcList="srcList" :oldSrcList="oldSrcList" @changeSrcList="changeSrcList"></elementImage> -->
                    <uploadResult
                      style="margin-left: 120px"
                      :resultList="upLoadFile"
                      @callBackResult="getFile"
                    />
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-row style="text-align: center; margin-top: 20px">
            <el-col :span="20">
              <el-form-item>
                <el-button
                  class="commonBut saveBtn"
                  type="primary"
                  @click="saveDoc"
                  v-show="isShowAdd"
                  :loading="canLogin"
                  >申报项目</el-button
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import common from '../../kits/common'
import { mapActions, mapState } from 'vuex'
export default {
  name: 'newProjectApplication',

  data() {
    //   验证工程造价
    var validateProjectCost = (rule, value, callback) => {
      // if(!isNaN(value)){
      //   value = value
      // }else {
      //   value = value.replace(/\s+/g, "");
      // }
      if (isNaN(value)) {
        value = value.replace(/\s+/g, '')
      }
      if (value === '') {
        callback(new Error('工程造价不能为空'))
      } else {
        var regCost = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
        if (!regCost.test(value)) {
          callback(new Error('工程造价范围格式不正确'))
        } else {
          callback()
        }
      }
    }
    // 验证建设周期
    var validateConCycle = (rule, value, callback) => {
      // if(!isNaN(value)){
      //   value = value
      // }else {
      //   value = value.replace(/\s+/g, "");
      // }
      if (isNaN(value)) {
        value = value.replace(/\s+/g, '')
      }
      if (value === '') {
        callback(new Error('建设周期不能为空'))
      } else {
        var ConCycle = /^\+?[1-9][0-9]*$/
        if (!ConCycle.test(value)) {
          callback(new Error('建设周期格式不正确'))
        } else {
          callback()
        }
      }
    }
    //验证企业名称
    var validateName = (rule, value, callback) => {
      value = value.replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('企业名称不能为空'))
      } else {
        if (value.length > 100) {
          callback(new Error('企业名称不能超过100个字符'))
        } else {
          if (this.formData.jsUscc !== '') {
            this.$refs.formData.validateField('jsUscc')
          }

          callback()
        }
      }
    }
    //验证uscc
    var validateUscc = (rule, value, callback) => {
      value = value.replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('统一社会信用代码不能为空'))
      } else {
        var regUscc = /^[0-9A-Z]{2}[0-9]{6}[0-9A-Z]{10}$/
        if (!regUscc.test(value)) {
          callback(new Error('统一社会信用代码格式不正确'))
        } else {
          callback()
          //   var companyName = this.formData.unitName;
          //   if(this.jsFlag == ""){
          //     this.validUscc(companyName,value,callback)
          //   }else {
          //     if((this.jsName != companyName || this.jsUscc != value || this.jsFlag == "2") && this.saveFlag == "1"){
          //         this.validUscc(companyName,value,callback);
          //       }else{
          //         callback();
          //     }
          //   }
        }
      }
    }
    var validAddress = (rule, value, callback) => {
      var that = this
      var address = that.formData.detailAddress.replace(/\s/g, '')
      setTimeout(function () {
        if (!that.lat || !address || (that.flag == false && !that.lat)) {
          that.flag = true
          return callback(new Error('请输入有效地址'))
        } else {
          callback()
        }
      }, 800)
    }
    var validateConAddress = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('请输入施工地址'))
      } else {
        if (value.length > 50) {
          callback(new Error('施工地址最多可输入50字'))
        } else {
          callback()
        }
      }
    }
    var checkUpLoadFileOrder = (rule, value, callback) => {
      if (this.upLoadFileOrder.length == 0) {
        return callback(new Error('请上传开工令附件'))
      } else {
        callback()
      }
    }
    // 武汉施工许可证
    var checkUpLoadFileLicense = (rule, value, callback) => {
      if (this.upLoadFileLicense.length == 0) {
        return callback(new Error('请上传施工许可证'))
      } else {
        callback()
      }
    }
    // 合同附件
    var checkUpLoadFile = (rule, value, callback) => {
      if (this.upLoadFile.length == 0) {
        return callback(new Error('请上传合同附件'))
      } else {
        callback()
      }
    }
    var validateManagerUpLoadFile = (rele, value, callback) => {
      if (this.managerUpLoadFile.length < 1) {
        return callback(new Error('必须上传项目经理资格证书'))
      } else {
        callback()
      }
    }
    var validateManUploadFiles = (rule, value, callback) => {
      if (this.manUploadFiles.length == 0) {
        return callback(new Error('请上传项目经理企业任命文件'))
      } else {
        callback()
      }
    }
    return {
      titleText: '新建申报',
      titleExplain: '',
      projectStatus: [],
      formData: {
        projectName: '',
        projectStatus: '',
        areaId: '',
        industry: '',
        category: '',
        projectCost: '',
        startDate: '',
        constructionCycle: '',
        projectType: '',
        companyName: '',
        uscc: '',
        detailAddress: '',
        unitName: '',
        jsUscc: '',
        license: '',
        proManagerName: '', //项目经理姓名
        proManagerCard: '', //项目经理身份证号
        proManagerTel: '', //项目经理手机号
        salaryDay: '',
        leader: '',
        leaderTel: '',
        pcLeader: '', //建设方项目负责人
        pcLeaderTel: '', //建设方项目负责人电话
        contractImgUrl: [], //合同附件
        managerImgUrl: [], //项目经理资质附件
        constructLocation: '', //施工地址
        isStateOwnedConstruction: '',
        contractSignDate: '',
      },
      upLoadFile: [], //附件
      srcList: [],
      oldSrcList: [],
      managerUpLoadFile: [], //项目经理资质附件
      managerSrcList: [],
      managerOldSrcList: [],
      upLoadFileLicense: [], //施工许可证附件
      srcListLicense: [],
      oldSrcListLicense: [],
      upLoadFileOrder: [], //开工令附件
      srcListOrder: [],
      oldSrcListOrder: [],
      formRules: {
        projectName: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' },
        ],
        projectStatus: [
          { required: true, message: '项目状态不能为空', trigger: 'change' },
        ],
        areaId: [
          { required: true, message: '所属区域不能为空', trigger: 'change' },
        ],
        industry: [
          { required: true, message: '所属行业不能为空', trigger: 'change' },
        ],
        category: [
          { required: true, message: '投资类别不能为空', trigger: 'change' },
        ],
        projectCost: [
          { required: true, validator: validateProjectCost, trigger: 'blur' },
        ],
        startDate: [
          { required: true, message: '开工日期不能为空', trigger: 'change' },
        ],
        constructionCycle: [
          { required: true, validator: validateConCycle, trigger: 'blur' },
        ],
        projectType: [
          { required: true, message: '工程类型不能为空', trigger: 'change' },
        ],
        unitName: [
          { required: true, validator: validateName, trigger: 'change' },
        ],
        jsUscc: [
          { required: true, validator: validateUscc, trigger: 'change' },
        ],
        detailAddress: [
          { required: true, validator: validAddress, trigger: 'blur' },
        ],
        proManagerName: [
          { required: true, message: '项目经理姓名不能为空', trigger: 'blur' },
        ],
        proManagerCard: [
          {
            required: true,
            pattern:
              /^(([1-9][0-9]{5}(19|20)[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}([0-9]|X|x))|([1-9][0-9]{5}[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}))$/,
            message: '请输入正确的身份证号',
            trigger: 'blur',
          },
        ],
        proManagerTel: [
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur',
          },
        ],
        salaryDay: [
          { required: true, message: '请选择工资发放日', trigger: 'change' },
        ],
        leader: [
          {
            required: true,
            message: '项目全权负责人姓名不能为空',
            trigger: 'blur',
          },
        ],
        leaderTel: [
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur',
          },
        ],
        pcLeader: [
          { required: true, message: '请输入项目负责人', trigger: 'blur' },
        ],
        pcLeaderTel: [
          { required: true, message: '请输入负责人手机号码', trigger: 'blur' },
        ],
        constructLocation: [
          { required: true, validator: validateConAddress, trigger: 'blur' },
        ],
        isStateOwnedConstruction: [
          {
            required: true,
            message: '请选择项目的施工总承包企业是否属于国有企业',
            trigger: 'change',
          },
        ],
        upLoadFileOrder: [
          {
            required: true,
            validator: checkUpLoadFileOrder,
            trigger: 'blur',
          },
        ],
        contractSignDate: [
          { required: true, message: '请选择合同签订日', trigger: 'change' },
        ],
        upLoadFileLicense: [
          {
            required: true,
            validator: checkUpLoadFileLicense,
            trigger: 'blur',
          },
        ],
        upLoadFile: [
          {
            required: true,
            validator: checkUpLoadFile,
            trigger: 'blur',
          },
        ],
        managerUpLoadFile: [
          {
            required: true,
            validator: validateManagerUpLoadFile,
            trigger: 'change',
          },
        ],
        manUploadFiles: [
          {
            required: true,
            validator: validateManUploadFiles,
            trigger: 'change',
          },
        ],
      },
      isShowMap: false, //是否显示地图
      lon: '',
      lat: '',
      LocationPoint: '',
      isShowBox: true,
      selectData: '',
      projectType: [], //工程类型
      category: [], //投资类别
      industry: [], //所属行业
      areaIdOpt: [], //列表区域下拉
      areaId: [],
      nickname: '',
      sgUscc: '',
      canLogin: false, //保存loading
      jsFlag: '',
      jsName: '',
      jsUscc: '',
      saveFlag: '1',
      back: true,
      isShowAdd: '',
      flag: true,
      salaryDayList: [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
      ],
      // 项目经理资格证书
      limitationFactorManager: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传文件最大数量设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'managerFiles', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'managerFilesForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目项目经理资质证书，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 施工许可证
      limitationFactorLicense: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'license', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'licenseForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传施工许可证，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 开工令
      limitationFactorOrder: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'startOrder', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'startOrderForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传开工令，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 合同信息
      limitationFactor: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'salaryExcel', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'salaryExcelForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目合同（必须包含项目名称、甲乙双方、工程造价、工期等必要内容），附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 任命书
      limitationFactorManFiles: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'manUploadFiles', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'manFilesForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目经理任命书，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },

      id: '',
      list: [],
      isNeedLicense: '', //施工许可证
      isNeedOrdFiles: '', //开工令附件
      isNeedUpLoadFile: '', //合同附件
      isNeedManagerName: '', //项目经理姓名
      isNeedManagerIdcard: '', //项目经理身份证号
      isNeedManagerTel: '', //项目经理手机号码
      isNeedMgFiles: '', //项目经理资格证书
      isAppointJson: '', //项目经理任命文件
      isNeedIsStateOwned: '', //是否国企施工项目
      isNeedContractSignDate: '', //合同签订日
      isNeedLicenseFiles: '', //武汉施工许可证
      manFilesOldSrcList: [], //任命书
      manFilesSrcList: [],
      manUploadFiles: [],
      isNeedAddress: '', //详细地址
      isNeedConstructLocation: '', //施工地址
      isNeedPcLeader: '', //建设方负责人
      isNeedPcLeaderTel: '', //建设方负责人手机号
      isNeedLeader: '',
      isNeedLeaderTel: '',
    }
  },
  async created() {
    await this.getIsNeed() //是否必填
    this.getAreaData()
    this.getSelecData('PROJECT_STATUS') //项目状态
    this.getSelecData('INDUSTRY') //所属行业
    this.getSelecData('PROJECT_INVESTMENT') //投资类别
    this.getSelecData('PROJECT_TYPE') //工程类型
    // 获取施工方名和信用代码
    this.getCurrent()
    let tempDate = this.$route.query.projectData
    if (tempDate) {
      this.getProlectInfo(tempDate)
    }
    if (this.$route.query.id) {
      this.id = this.$route.query.id
      this.getProlectInfo(this.$route.query.id)
    }
    this.isShowAdd =
      this.$store.state.buttonLimitsArr.indexOf('projectDeclareList:add') >
        -1 ||
      this.$store.state.buttonLimitsArr.indexOf('projectDeclareListSGF:add') >
        -1
  },
  computed: {
    ...mapState(['investmentOptions']),
  },
  mounted() {
    if (!this.isWhUser()) {
      // delete this.formRules.isStateOwnedConstruction
    }
    this.$nextTick(function () {
      this.getLocation()
    })
  },
  methods: {
    goBackList() {
      this.$router.push({
        path: '/home/project/projectDeclareList',
        name: 'projectDeclareList',
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/project/projectDeclareList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    getProlectInfo(id) {
      this.axios({
        method: 'post',
        url: 'api-p/projectapplication/expand/finddetailbyid',
        data: {
          id: id,
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            let projectInfo = response.data.result
            let data = {
              id: id,
              projectName: projectInfo.projectName, //项目名称
              license: projectInfo.license, //施工许可证
              projectStatus: projectInfo.projectStatus, //项目状态
              areaId: projectInfo.areaId, //所属区域
              industry: projectInfo.industryId, //所属行业
              category: projectInfo.investment, //投资类别
              projectCost: projectInfo.total, //工程造价
              startDate: projectInfo.startDate, //开工日期
              constructionCycle: projectInfo.cycle, //建设周期
              detailAddress: projectInfo.address, //详细地址
              projectType: projectInfo.typeId, //工程类型
              unitName: projectInfo.pcName, //建设方单位名称
              jsUscc: projectInfo.pcUscc, //建设方统一社会信用代码
              pbName: projectInfo.pbName, //施工方单位名称
              pbUscc: projectInfo.pbUscc, //施工方统一社会信用代码\
              proManagerName: projectInfo.managerName,
              proManagerCard: projectInfo.managerIdcard,
              proManagerTel: projectInfo.managerTel,
              salaryDay: projectInfo.salaryDate,
              cityId: projectInfo.cityId,
              countyId: projectInfo.countyId,
              provinceId: projectInfo.provinceId,
              lon: projectInfo.lon,
              lat: projectInfo.lat,
              leader: projectInfo.leader,
              leaderTel: projectInfo.leaderTel,
              pcLeader: projectInfo.pcLeader,
              pcLeaderTel: projectInfo.pcLeaderTel,
              constructLocation: projectInfo.constructLocation,
              isStateOwnedConstruction: projectInfo.isStateOwnedConstruction
                ? projectInfo.isStateOwnedConstruction
                : '',
              contractSignDate: projectInfo.contractSignDate,
            }
            this.formData = data
            if (!this.isWhUser()) {
              // delete this.formRules.isStateOwnedConstruction
            }
            //判断返回区域数组，确定当前是省级项目还是市级项目
            let firstAreaId = this.areaIdOpt[0].value
            if (data.countyId == data.areaId) {
              this.areaId =
                firstAreaId == data.provinceId
                  ? [data.provinceId, data.cityId, data.countyId]
                  : [data.cityId, data.countyId]
            } else {
              this.areaId =
                firstAreaId == data.provinceId
                  ? [data.provinceId, data.cityId, data.countyId, data.areaId]
                  : [data.cityId, data.countyId, data.areaId]
            }

            this.upLoadFile = projectInfo.contractFiles
            this.managerUpLoadFile = projectInfo.managerFiles
            this.upLoadFileLicense = projectInfo.licenseFilesView || [] //施工许可证
            this.upLoadFileOrder = projectInfo.orFiles
            this.lon = data.lon
            this.lat = data.lat
            this.manUploadFiles = projectInfo.appointFiles
          } else {
            this.$message({
              message: response.data.errorMsg,
              type: 'error',
            })
          }
        })
        .catch((error) => {})
    },
    getLocation() {
      var that = this
      var map = new BMap.Map('allmap')

      function myFun(result) {
        var cityName = result.name
        map.setCenter(cityName)
        that.LocationPoint = cityName
      }
      var myCity = new BMap.LocalCity()
      myCity.get(myFun)
    },
    showMap() {
      this.isShowMap = true
      this.isShowBox = false
      var addressName = this.formData.detailAddress
      this.$nextTick(function () {
        // 详细地址获取焦点
        this.$refs.inputDetailAdr.focus()
        this.initMap()
        setTimeout(function () {
          if ($('.tangram-suggestion-main').length == 1) {
            $('#suggestId').val(addressName)
          }
        }, 50)
        $('#suggestId').val(addressName)
      })
    },
    hideMap() {
      var that = this
      that.$refs.inputDetailAdr.blur()
      setTimeout(function () {
        if (that.selectData == '1') {
          that.isShowMap = true
          that.selectData = ''
          that.isShowBox = false
        } else {
          that.isShowMap = false
          that.isShowBox = true
        }
      }, 500)
    },
    initMap() {
      var that = this
      // 百度地图API功能
      function G(id) {
        return document.getElementById(id)
      }

      var map = new BMap.Map('l-map')
      if (that.formData.detailAddress) {
        that.isShowMap = true
        this.isShowBox = false

        var point = new BMap.Point(that.lon, that.lat)

        map.centerAndZoom(point, 16)

        var mk = new BMap.Marker(point)
        map.addOverlay(mk)
        map.panTo(point)
        // 初始化可拖拽
        mk.enableDragging()
        mk.addEventListener('dragend', function (e) {
          that.lon = e.point.lng
          that.lat = e.point.lat
          var myGeo = new BMap.Geocoder()
          // 根据坐标得到地址描述
          myGeo.getLocation(
            new BMap.Point(e.point.lng, e.point.lat),
            function (result) {
              if (result) {
                that.formData.detailAddress = result.address
              }
            }
          )
        })
      } else {
        var myGeo = new BMap.Geocoder()
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(
          that.LocationPoint,
          function (point) {
            if (point) {
              map.centerAndZoom(point, 16)
              var mk = new BMap.Marker(point)
              map.addOverlay(mk)
              map.panTo(point)
              // 初始化可拖拽
              mk.enableDragging()
              mk.addEventListener('dragend', function (e) {
                that.lon = e.point.lng
                that.lat = e.point.lat
                var myGeo = new BMap.Geocoder()
                // 根据坐标得到地址描述
                myGeo.getLocation(
                  new BMap.Point(e.point.lng, e.point.lat),
                  function (result) {
                    if (result) {
                      that.formData.detailAddress = result.address
                    }
                  }
                )
              })
            } else {
              // alert("您选择地址没有解析到结果!");
            }
          },
          '北京市'
        )
      }

      //增加滚轮放大缩小
      map.enableScrollWheelZoom(true)

      //增加滚轮放大缩小
      var ac = new BMap.Autocomplete({
        //建立一个自动完成的对象
        input: 'suggestId',
        location: map,
      })

      ac.addEventListener('onhighlight', function (e) {
        // that.selectData = "1";
        //鼠标放在下拉列表上的事件
        var str = ''
        var _value = e.fromitem.value
        var value = ''
        if (e.fromitem.index > -1) {
          value =
            _value.province +
            _value.city +
            _value.district +
            _value.street +
            _value.business
        }
        str =
          'FromItem<br />index = ' + e.fromitem.index + '<br />value = ' + value

        value = ''
        if (e.toitem.index > -1) {
          _value = e.toitem.value
          value =
            _value.province +
            _value.city +
            _value.district +
            _value.street +
            _value.business
        }
        str +=
          '<br />ToItem<br />index = ' +
          e.toitem.index +
          '<br />value = ' +
          value
        G('searchResultPanel').innerHTML = str
      })

      var myValue
      ac.addEventListener('onconfirm', function (e) {
        that.selectData = '1'
        var suggestVal = $('#suggestId').val()
        $('#suggestId').bind('input propertychange', function () {
          if (that.formData.detailAddress != suggestVal) {
            that.flag = false
            that.lon = ''
            that.lat = ''
          }
        })
        //鼠标点击下拉列表后的事件
        var _value = e.item.value
        myValue =
          _value.province +
          _value.city +
          _value.district +
          _value.street +
          _value.business
        G('searchResultPanel').innerHTML =
          'onconfirm<br />index = ' +
          e.item.index +
          '<br />myValue = ' +
          myValue
        that.formData.detailAddress = myValue
        setPlace()
      })

      function setPlace() {
        map.clearOverlays() //清除地图上所有覆盖物
        function myFun() {
          var pp = local.getResults().getPoi(0).point //获取第一个智能搜索的结果
          map.centerAndZoom(pp, 18)
          var marker = new BMap.Marker(pp)
          map.addOverlay(marker) //添加标注
          that.lon = pp.lng
          that.lat = pp.lat
          var geoc = new BMap.Geocoder()
          marker.enableDragging()
          marker.addEventListener('dragend', function (e) {
            that.lon = e.point.lng
            that.lat = e.point.lat
            var myGeo = new BMap.Geocoder()
            // 根据坐标得到地址描述
            myGeo.getLocation(
              new BMap.Point(e.point.lng, e.point.lat),
              function (result) {
                if (result) {
                  that.formData.detailAddress = result.address
                }
              }
            )
          })
        }
        var local = new BMap.LocalSearch(map, {
          //智能搜索
          onSearchComplete: myFun,
        })
        local.search(myValue)
      }
    },
    getSelecData(type) {
      var url
      if (type == 'PROJECT_INVESTMENT' || type == 'PROJECT_STATUS') {
        url = 'api-p/project/expand/findstatusbytype'
      } else {
        url = 'api-bs/base/dicitem/findbytype'
      }
      this.axios({
        method: 'post',
        url: url,
        data: { type: type },
      })
        .then((res) => {
          if (type == 'INDUSTRY') {
            this.industry = res.data.result
          } else if (type == 'PROJECT_TYPE') {
            this.projectType = res.data.result
          } else if (type == 'PROJECT_INVESTMENT') {
            this.category = res.data.result
          } else if (type == 'PROJECT_STATUS') {
            this.projectStatus = res.data.result
          }
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取数据失败',
            type: 'error',
          })
        })
    },
    //获取选中的区域最后一级id
    getAreaId() {
      this.formData.areaId = this.areaId[this.areaId.length - 1]
    },
    getAreaData() {
      this.axios({
        method: 'post',
        url: 'api-bs/areadic/base/areacombobox',
        data: {
          areaId: this.$store.state.areaInfoArr.areaId,
        },
      })
        .then((resp) => {
          if (!resp.data.hasError) {
            this.areaIdOpt = resp.data.result
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: resp.data.errorMsg,
              type: 'error',
            })
          }
        })
        .catch((resp) => {
          this.$message.error('数据获取失败')
        })
    },
    saveDoc() {
      this.saveFlag = '2'
      this.canLogin = true
      if (this.jsFlag == '2') {
        this.$message({
          showClose: true,
          duration: 3000,
          message: '企业名称与统一社会信用代码不匹配',
          type: 'error',
        })
        this.isSubmit = false
        this.saveFlag = '1'
        return
      }
      this.$refs['formData'].validate((valid) => {
        if (valid) {
          this.saveFlag = '1'

          this.ajaxSubmit()
        } else {
          this.saveFlag = '1'
          this.selectData = ''
          this.canLogin = false
          return false
        }
      })
    },
    ajaxSubmit() {
      let data = {
        projectName: this.formData.projectName, //项目名称
        license: this.formData.license, //施工许可证
        projectStatus: this.formData.projectStatus, //项目状态
        areaId: this.formData.areaId, //所属区域
        industryId: this.formData.industry, //所属行业
        investment: this.formData.category, //投资类别
        total: this.formData.projectCost, //工程造价
        startDate: this.formData.startDate, //开工日期
        cycle: this.formData.constructionCycle, //建设周期
        address: this.formData.detailAddress, //详细地址
        typeId: this.formData.projectType, //工程类型
        pcName: this.formData.unitName.replace(/\s+/g, ''), //建设方单位名称
        pcUscc: this.formData.jsUscc.replace(/\s+/g, ''), //建设方统一社会信用代码
        pbName: this.nickname, //施工方单位名称
        pbUscc: this.sgUscc, //施工方统一社会信用代码\
        managerName: this.formData.proManagerName,
        managerIdcard: this.formData.proManagerCard,
        managerTel: this.formData.proManagerTel,
        salaryDate: this.formData.salaryDay,
        lon: this.lon,
        lat: this.lat,
        leader: this.formData.leader, //---项目负责人
        leaderTel: this.formData.leaderTel, //---项目负责人电话
        pcLeader: this.formData.pcLeader, //---建设方项目负责人
        pcLeaderTel: this.formData.pcLeaderTel, //---建设方项目负责人电话
        files: JSON.stringify(this.upLoadFile), //---项目合同附件
        mgFiles: JSON.stringify(this.managerUpLoadFile), //项目经理资格证书
        licenseFiles: JSON.stringify(this.upLoadFileLicense), //施工许可证
        ordFiles: JSON.stringify(this.upLoadFileOrder), //开工令
        constructLocation: this.formData.constructLocation,
        contractSignDate: this.formData.contractSignDate,
        appointJson: JSON.stringify(this.manUploadFiles),
      }
      if (this.$route.query.id) {
        data.id = this.$route.query.id
      }
      // if(this.isWhUser()){
      data.isStateOwnedConstruction = this.formData.isStateOwnedConstruction
      // }
      this.axios({
        method: 'post',
        url: 'api-p/projectapplication/expand/add',
        data: data,
      })
        .then((resp) => {
          this.canLogin = false
          if (!resp.data.hasError) {
            this.$confirm(
              '该项目已提交申报，请等待当地监管部门审核',
              '提交申报成功',
              {
                confirmButtonText: '去看看',
                cancelButtonText: '继续申报',
                type: 'success',
                center: true,
              }
            )
              .then(() => {
                // 点击去看看按钮则跳转至该项目的申报详情页面
                this.$router.push({
                  path: '/home/project/projectDeclareDetail',
                  name: 'projectDeclareDetail',
                  query: { id: this.$route.query.id || resp.data.result.id },
                })
                this.$store.commit('CHANGE_SLIDER_NAME', {
                  oldUrl: '/home/project/projectDeclareList',
                  newUrl: this.$router.currentRoute.fullPath,
                })
              })
              .catch(() => {
                this.formData.license = ''
                this.formData.pcLeader = ''
                this.formData.pcLeaderTel = ''
                this.areaId = []
                this.upLoadFile = []
                this.managerUpLoadFile = []
                this.manUploadFiles = []
                this.upLoadFileOrder = []
                this.formData.contractSignDate = ''
                this.$refs['formData'].resetFields()
              })
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: resp.data.errorMsg,
              type: 'error',
            })
          }
        })
        .catch((resp) => {
          this.saveFlag = '1'
          this.canLogin = false
          this.$message.error('数据获取失败')
        })
    },
    validProName() {
      if (this.formData.projectName) {
        this.axios({
          method: 'post',
          url: 'api-p/projectapplication/expand/check',
          data: { projectName: this.formData.projectName },
        })
          .then((resp) => {
            if (resp.data.hasError) {
              this.$message({
                showClose: true,
                duration: 3000,
                message: resp.data.errorMsg,
                type: 'error',
              })
            }
          })
          .catch((resp) => {
            this.$message.error('数据获取失败')
          })
      }
    },
    // 获取施工方名和信用代码
    getCurrent() {
      this.axios({
        method: 'get',
        url: 'api-u/users/current',
      })
        .then((resp) => {
          this.nickname = resp.data.nickname
          this.sgUscc = resp.data.uscc
        })
        .catch((resp) => {
          this.$message.error('数据获取失败')
        })
    },
    /**
     * @description: 改变图片地址
     */
    changeSrcList(val) {
      this.srcList = val
    },
    /**
     * @description: 改变图片地址
     */
    changeManagerSrcList(val) {
      this.managerSrcList = val
    },
    getFileListManager(val) {
      this.managerOldSrcList.push(val)
      this.managerSrcList.push(val)
    },
    getFileManager(val) {
      this.managerUpLoadFile = val
    },
    getFileList(val) {
      this.oldSrcList.push(val)
      this.srcList.push(val)
    },
    getFile(val) {
      this.upLoadFile = val
    },
    //施工许可证
    getFileListLicense(val) {
      this.oldSrcListLicense.push(val)
      this.srcListLicense.push(val)
    },
    getFileLicense(val) {
      this.upLoadFileLicense = val
    },
    // 开工令
    getFileListOrder(val) {
      this.oldSrcListOrder.push(val)
      this.srcListOrder.push(val)
    },
    getFileOrder(val) {
      this.upLoadFileOrder = val
    },
    // 项目经理任命书
    getFileListManFiles(val) {
      this.manFilesOldSrcList.push(val)
      this.manFilesSrcList.push(val)
    },
    getFileManFiles(val) {
      this.manUploadFiles = val
    },
    changeSrcListOrder(val) {
      this.srcListOrder = val
    },
    validUsccAndCompany(companyName, uscc) {
      if (companyName && uscc) {
        this.axios({
          method: 'post',
          url: 'api-c/companyaudit/base/validcompanybyproject',
          data: {
            name: companyName.replace(/\s+/g, ''),
            uscc: uscc.replace(/\s+/g, ''),
          },
        })
          .then((res) => {
            if (!res.data.hasError) {
              this.$message({
                message: '已通过校验',
                type: 'success',
              })
            } else {
              if (res.data.errorCode == 'unmatched') {
                this.$message({
                  message: '未通过校验，请确认信息是否准确',
                  type: 'warning',
                })
              }
            }
          })
          .catch((error) => {
            this.$message.error('验证失败')
          })
      }
    },
    getIsNeed() {
      return this.axios({
        method: 'post',
        url: 'api-m/fieldconfig/base/getbymaintype',
        data: {
          mainType: 'PROJECT_BUILD',
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            this.list = response.data.result
            // this.$set(this.listObject,'isNeedManagerTel',element.isNeed)
            this.list.forEach((element) => {
              if (element.code == 'license') {
                //施工许可证
                this.isNeedLicense = element.isNeed
              } else if (element.code == 'ordFiles') {
                //开工令附件
                this.isNeedOrdFiles = element.isNeed
              } else if (element.code == 'isStateOwnedConstruction') {
                //是否国企施工项目
                this.isNeedIsStateOwned = element.isNeed
              } else if (element.code == 'contractSignDate') {
                //合同签订日
                this.isNeedContractSignDate = element.isNeed
              } else if (element.code == 'licenseFiles') {
                //武汉施工许可证
                this.isNeedLicenseFiles = element.isNeed
              } else if (element.code == 'files') {
                //合同附件
                this.isNeedUpLoadFile = element.isNeed
              } else if (element.code == 'managerName') {
                //项目经理姓名
                this.isNeedManagerName = element.isNeed
              } else if (element.code == 'managerIdcard') {
                //项目经理身份证号managerIdcard
                this.isNeedManagerIdcard = element.isNeed
              } else if (element.code == 'managerTel') {
                //项目经理手机号码
                this.isNeedManagerTel = element.isNeed
              } else if (element.code == 'mgFiles') {
                //项目经理资格证书
                this.isNeedMgFiles = element.isNeed
              } else if (element.code == 'appointJson') {
                //项目经理任命文件
                this.isAppointJson = element.isNeed
              } else if (element.code == 'address') {
                this.isNeedAddress = element.isNeed
              } else if (element.code == 'constructLocation') {
                this.isNeedConstructLocation = element.isNeed
              } else if (element.code == 'pcLeader') {
                this.isNeedPcLeader = element.isNeed
              } else if (element.code == 'pcLeaderTel') {
                this.isNeedPcLeaderTel = element.isNeed
              } else if (element.code == 'leader') {
                this.isNeedLeader = element.isNeed
              } else if (element.code == 'leaderTel') {
                this.isNeedLeaderTel = element.isNeed
              }
            })
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
  },
  watch: {
    'formData.detailAddress': {
      handler(newVal, oldVal) {
        if (oldVal) {
          if (newVal != oldVal) {
            //  this.lon = "";
            //  this.lat = ""
          }
        }
      },
      deep: true,
    },
  },
}
</script>

<style lang="less" scoped>
.container {
  .mainCon {
    padding: 24px;
  }
  .mainC {
    background: #fff;
    padding-top: 24px;
    .infoTitle {
      font-size: 16px;
      padding: 16px 24px;
      background: #f5f7fb;
      margin-bottom: 24px;
      color: #333;
      font-weight: 700;
    }
    .proInputWidth {
      width: 75%;
    }
    .minInputWidth {
      width: 35%;
      margin-right: 8px;
    }
  }
  .tipBar2 {
    height: 88px;
    margin: 6px 20px;
    margin-bottom: 24px;
  }
  .hint {
    float: left;
    display: block;
    width: 24%;
    padding-left: 5%;
  }
  .imgLabel {
    display: inline-block;
    // width: 80px;
    float: left;
  }
  .picCss {
    // height: 80px;
    // width: 80px;
    // font-size: 88px;
    color: #d0d0d8;
  }
  .lineCss {
    width: 100%;
    height: 8px;
    margin-top: 40px;
  }
  .stepCss {
    float: left;
    display: block;
    width: 12%;
  }
  .hintCss {
    display: block;
    margin-left: 85px;
    margin-top: 15px;
  }
  .fontCss {
    font-size: 14px;
    color: #666;
    display: block;
    // text-overflow: -o-ellipsis-lastline;
    // overflow: hidden;
    // text-overflow: ellipsis;
    // display: -webkit-box;
    // -webkit-line-clamp: 2;
    // line-clamp: 2;
    // /*! autoprefixer: off */
    // -webkit-box-orient: vertical;
  }
  .noRule {
    text-align: center;
    img {
      margin: 60px 0;
    }
  }
  .uploadBox {
    position: relative;
    .uploadImg {
      width: 96px;
      height: 36px;
      color: #009588;
      border: 1px solid #009588;
      line-height: 10px;
    }
    .uploadImgState {
      font-size: 14px;
      color: #999999;
      margin-left: 12px;
    }
    .upLoadDom {
      position: absolute;
      top: 0;
      left: 0;
      opacity: 0;
      input {
        width: 100px;
        height: 36px;
        cursor: pointer;
      }
    }
  }
  .imgStyle {
    padding-left: 100px;
    margin-top: 24px;
    li {
      position: relative;
      margin-right: 20px;
      margin-top: 10px;
      i {
        position: absolute;
        right: -6px;
        top: -10px;
        font-size: 20px;
      }
    }
  }
}
.warpLabel {
  /deep/.el-form-item__label {
    line-height: 20px;
  }
}
</style>
